  PUBLIC sz_ftp

   * Make it so Foxpro can find our FTP Class
	SET PROCEDURE TO ftp.prg ADDITIVE
   
   * Create a FTP Object
	sz_ftp = CREATEOBJECT('ftp_service')

   * Try to get a handle into the Internet and Connect Briefly with the FTP Site
   * Note: Insert your USER ID, PASSWORD, FTP ADDRESS, PORT # Here  
   * Note: ("21" is the Default Port)
   
	IF sz_ftp.OpenInternet("anonimo","anonimo","192.168.150.43", "21") 
	
		MessageBox("Successful Connection", 64, "FTP Message")
	
	   * Display the Inital Directory
		? "--- Inital Directory"
		ListDir()
		
		
	   * Change to that directory
		? "--- Changing Directory to Dir_Test"
		IF !sz_ftp.ChangeFtpDirectory("assbasalud\sics\")
			?sz_ftp.GetErrorCode(.T.)
		ENDIF
	    ListDir()
	
	   * Copy up a file to the server
	   * NOTE: If you get Error #2 Cant Find File.  It couldn't find this 
	   *       TESTFILE.TXT file.
		? "--- copy File from FTP Server"		
		IF !sz_ftp.GetFtpFile("atencion.exe", "c:\ASSBASALUD\SICS\atencion.exe",.f.)
			?sz_ftp.GetErrorCode(.T.)
        ELSE
          MESSAGEBOX("Sistema actualizado exitosamente",0,"ASSBASALUD E.S.E")  
		ENDIF
		ListDir()


		sz_ftp.CloseInternet()
				
	  ELSE
	  	MessageBox("No Connection Made", 64, "FTP Message")
	  	sz_ftp.CloseInternet()
	  	?sz_ftp.GetErrorCode(.T.)
	  	
	 ENDIF

   RETURN

  ***************************************************
	PROCEDURE ListDir

		
		LOCAL lcOutput, lcDirName, laDirArray

      * Reset the variable to hold the file array.  
      * The Object redefines the variable to an array.
		laDirArray = ""
		
      * Get the Current Directory Name
		IF !sz_ftp.GetFtpDirectory(@lcDirName)
			sz_ftp.GetErrorCode(.T.)
			lcDirName = ''
		ENDIF
		
	  * Get the Files in the Current Directory
	  * This one always returns an Error.  When the API Function that gets the files
	  * can't find any more files, it return the Error 'ERROR_NO_MORE_FILES' 
		IF !sz_ftp.GetFtpDirectoryArray(@laDirArray, "*.*") 
		   * Error 18 always returns if the directory is empty
			IF !EMPTY(laDirArray) OR sz_ftp.GetErrorCode(.F.) != 18
		    	sz_ftp.GetErrorCode(.T.)
		    ENDIF
		ENDIF
		
	   * Output the Current Directory 
		? 
		? 'FTP Directory: ' + lcDirName 
		
	   * Interate through our array of files
		IF !EMPTY(laDirArray)  && If Empty, there were no files found in the current Directory.
			FOR x = 1 TO ALEN(laDirArray, 1)
			   
			  * Pad up a String with some file information.
			   lcOutput = '   ' + PADR(laDirArray[x, 1], 25) + PADL(STR(laDirArray[x, 3]), 12) + ;
			   				 ' ' + PADR(DTOC(laDirArray[x, 6]), 14) + laDirArray[x, 7]
			  * Output the File Information
			   ? lcOutput
				
			ENDFOR
		ENDIF
	
	  * Just move a line down.
		?
				
	RETURN